home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / qh_putback.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  45 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / Insert object at the beginning of the process_queue.
  8. / It is an error if there is no room.
  9. nt queue_head::unget(process_object *p)
  10.  
  11.    if (debug) /*DELETE*/ cerr << "queue_head" << this << "::unget()\n";
  12.    process_queue *q = qh_queue;
  13.  
  14.    if (p->po_next)
  15. error("queue_head::unget(): object on another queue");
  16.  
  17.    if (q->q_count >= q->q_max)
  18. switch (qh_mode)
  19.     {
  20.     case Q_WMODE:
  21.     case Q_EMODE:
  22.     error("queue_tail::unget(): full queue");
  23.         /* FALLTHROUGH */
  24.  
  25.     case Q_ZMODE:
  26.         if (debug) /*DELETE*/ cerr << "<<<< queue_head" << this << "::unget() <- 0\n";
  27.     return 0;
  28.     }
  29.  
  30.    // new object on empty queue
  31.    if (q->q_count++ == 0)
  32. q->q_last = p->po_next = p;
  33.  
  34.    // objects are already on the queue
  35.    else
  36. {
  37. process_object *last = q->q_last;
  38. p->po_next = last->po_next;
  39. last->po_next = p;
  40. }
  41.  
  42.    if (debug) /*DELETE*/ cerr << "<<<< queue_head" << this << "::unget() <- 1\n";
  43.    return 1;
  44.  
  45.